A program sample demonstrating how to read and write directly to the Ethernet driver using the Open Transport XTI API's.
Description
The OTLLCTest program demonstrates the use of the Open Transport XTI API's to access the Ethernet driver to either read or write data directly. The "write" test, sends 10005 packets of 1500 bytes each out onto the wire in a loop. You can control how often WaitNextEvent is called, in order to throttle the output. In "read" mode, the test programThis program is also a useful tool to check Ethernet drivers with to see if they properly send "raw mode" packets and whether they can receive packets in a timely manner.
OTLLCTest demonstrate the following programming technique
1. Using OT Option Management to enable "raw mode" ethernet connections and to detect whether the underlying driver is based on the original ethernet template, or on the Mentat and recent Apple Ethernet template. This distinction is important for programs receiving raw mode data in that Mentat and Apple Ethernet template based drivers prepend a 24 byte header to the beginning of the data packet.
In order to keep from having to specify a target system's ethernet address, the test programs has the receiver program add a multicast address connection. The sender test, sends packets to this multicast address. The number of packets (10005), the SAP address (and SNAP address if the SAP is 0xAA), and the multicast address are defined in the header file OTLLCTest.h.
Using OTLLCTest
The OTLLCTest program is used to either send or receive data. To quit the program at any time, press Command-Q. To abort a portion of the test, press Command-A. One would set up a copy of the test program to read data and a different copy on another system to send data.
To send 10000 packets
1. Launch OTLLCTest. The program displays the name of the Ethernet connection that AppleTalk is currently using and a list of the available Ethernet ports available on the system.
2. When prompted, enter the name of the ethernet port on which to send data from.
3. When prompted, enter whether you want the program to use raw mode or not - there is no difference in program performance whether raw mode is enabled ot not.
4. When prompted, enter 's' to indicate that you want to send packets
5. When prompted, enter 'y', 'n' or 'q' as to whether to turn on AckSends. There is a significant perfomrance penalty based on the implementation of the test program if AckSends is enabled.
6. When prompted, enter a timer threshold - really this is the number of packets to send before calling WNE. The smaller the number, the more frequently, WNE is called. Enter 10000 to tell the test program to never call WNE
7. You are now ready to run. Click the mouse to begin the test.
To receive 10000 packets
1. Launch OTLLCTest. The program displays the name of the Ethernet connection that AppleTalk is currently using and a list of the available Ethernet ports available on the system.
2. When prompted, enter the name of the ethernet port on which to send data from.
3. When prompted, enter whether you want the program to use raw mode or not - there is no difference in program performance whether raw mode is enabled ot not.
4. When prompted, enter 'r' to indicate that you want to receive packets
5. You are now ready to run. Click the mouse to begin the test. This allows you to set up a sender.
While receiving WNE is called periodically so that you can switch out to another program while the receive test is under way.
After either test is run, OTLLCTest displays some statistics. You are prompted as to whether you want to run the test again.
Building the Code
This sample was built using the Metrowerks CodeWarrior IDE 2.1 environment and the Open Transport 1.2 SDK interfaces and libraries, along with the Universal Interfaces and Libraries v3.1. The program was originally compiled using the OT 1.1.2 SDK and run successfully under OT 1.1.2. There is a known issue with enabling rawmode on OT 1.1.2 and earlier on ethernet drivers which are based on the mentat template. It will not work. If the Option Management call fails to enable raw mode, then this mode is not used.
To rebuild the project, open it in CodeWarrior, change the access path as appropriate to point to the Open Tpt Client Developer folder in the OT 1.3 (or newer) SDK, and choose Make from the Project menu.
If you open the OTLLCTest.h header file, you will find that the SAP is set for 0xE0, or type 2 IPX. You may also specify different SAP's or SNAP addresses if the SAP address is set for 0xAA.
Limitations:
This sample reuires the presence of Open Transport 1.1.2 or greater.
Copyright (work in progress) Apple Computer, Inc
You may incorporate this sample code into your applications without restriction, though the sample code has been provided "AS IS" and the responsibility for its operation is 100% yours. However, what you are not permitted to do is to redistribute the source as "DSC Sample Code"
after having made changes. If you're going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple Sample Code, but that you've made changes.
Bug Reports:
If you find any bugs, please send them to "dts@apple.com" and include "Attn: Rich Kubota" and I will try to address them.